package com.hjduan.spring.cloud.request.controller;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.hjduan.spring.cloud.request.service.City;
import com.hjduan.spring.cloud.request.service.FeignService;

@RestController
public class FeignController {
    @Autowired
    private FeignService feignService;

    @ApiOperation(value = "获取city信息", notes = "根据id获取city")// 使用该注解描述接口方法信息
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "city表ID", required = true, dataType = "Long", paramType = "path")
    })// 使用该注解描述方法参数信息，此处需要注意的是paramType参数，
    @RequestMapping(value = "/feign/view/{id}", method = RequestMethod.GET)
    public City getCity(@PathVariable Integer id) {
        System.out.println(id);
        return feignService.getCityService(id);
    }

    @Value("${server.port}")
    String luckyWord;


    @Value("${spring.datasource.druid.max-active}")
    private String url;

    @ApiOperation(value = "获取的配置中心属性", notes = "属性")// 使用该注解描述接口方法信息
    @RequestMapping("/url")
    public String url() {

        return this.url;
    }
}
